$("footer").load("html/footer.html");

$(function() {
	$.get(
		'goodsAndShoppingCart/getGoodsList.php', {
			"typeId": 1,
		},
		function(data) {
			let dob =  JSON.parse(data);
			console.log(dob);
			// console.log(dob[0].goodsName);
			// console.log(dob.length);
			let oUl = document.getElementById("append-ul");
			for (let i = 0; i < dob.length; i++) {
				let oLi = document.createElement('li');
				oUl.appendChild(oLi);
				let oDiv = document.createElement("div");
				oDiv.style.backgroundImage = `url('${dob[i].goodsImg}')`;
				oLi.appendChild(oDiv);
				let oP = document.createElement("p");
				oP.innerHTML = dob[i].goodsName;
				oLi.appendChild(oP);
				let ospan = document.createElement("span");
				ospan.innerHTML ='￥:' + dob[i].goodsPrice;
				oLi.appendChild(ospan);
				let oBtn = document.createElement("h6");
				oBtn.innerHTML = `
				<a class="btn1" id="btn1">查看详情</a>
				<a class="btn2" id="btn2">加入购物车</a>
				`
				oLi.appendChild(oBtn);
			}
			$("#append-ul li").click(function(){
				let oId = $(this).index();
				console.log(oId);
				location.href = 'ProductDetails.html'+"?"+oId;
			});	
		}	
	);
});
